<?php
header("Content-type: text/html; charset=utf-8");
$link = mysqli_connect('localhost','root','','my_database');
if (!$link) {
    exit("数据库连接出错".mysqli_connect_error());
} 

if(!mysqli_set_charset($link,'utf8')){
    exit("数据库字符出错".mysqli_error($link));
}
// echo "连接成功";

?>